﻿using ApiConceptsFramework.Concepts.Properties;
using ApiConceptsFramework.Contract;
using FluentAssertions;
using NUnit.Framework;
using System;
using System.Collections.Generic;
using System.Linq;

namespace test.ApiConceptsFramework.Concepts.Properties
{
	[TestFixture]
	public class UsageOfReturnParameterTests
	{
// ReSharper disable UnusedMember.Local
		class TestClass
		{
			public void NoParameters() { }
			public string SingleReturnParameter() { return null; }
		}
// ReSharper restore UnusedMember.Local

		[Test, Sequential]
		public void Complexity_of_return_value_depends_on_usage(
			[Values("NoParameters", "SingleReturnParameter", "NoParameters", "SingleReturnParameter")] string member,
			[Values(true,true,false,false)] bool returnValueIsUsed,
			[Values(0, UsageOfReturnParameter.ReturnParameterComplexity, 0, 0)] int expectedResult)
		{
			//Arrange
			var measurableProperty = new UsageOfReturnParameter();
			var method = typeof(TestClass).GetMember(member).First();

			//Act
			var target = new MeasurableTarget { Type = typeof(TestClass), Member = method, ReturnedValueIsUsed = returnValueIsUsed };
			var result = measurableProperty.CalculateComplexity(target, IDE.VisualStudioOrSimilar);

			//Assert
			result.Should().Be(expectedResult);
			Console.WriteLine("Complexity of " + member + " = " + result);
		}
	}
}
